package cn.wolfcode.wolf2w.common.core.query;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.Getter;
import lombok.Setter;


import java.io.Serializable;

@Getter
@Setter
@ApiModel(value = "查询对象",description = "分页查询的父类")
@ApiResponses({
        @ApiResponse(code = 200,message = "成功"),
        @ApiResponse(code = 400,message = "参数错误"),
        @ApiResponse(code = 401,message = "未认证"),

        @ApiResponse(code = 500,message = "服务器错误"),
        @ApiResponse(code = 404,message = "未找到"),
        @ApiResponse(code = 403,message = "权限不足"),

})
public class QueryObject implements Serializable {
    @ApiModelProperty(value = "当前页",name = "currentPage",dataType = "int",
            required = true,example = "1")
    private int currentPage = -1;
    @ApiModelProperty(value = "当前页",name = "pageNum",dataType = "int",
            required = false,example = "1")
    private int pageNum = -1;
    @ApiModelProperty(value = "每页条数",name = "pageSize",dataType = "int",
            required = true,example = "10")
    private int pageSize = 10;
    @ApiModelProperty(value = "查询关键字",name = "keyword",dataType = "String",
            required = false,example = "")
    private String keyword;

    public int getCurrentPage(){
        if(currentPage != -1){
            return this.currentPage;
        }
        if(currentPage == -1 && pageNum != -1){
            return pageNum;
        }
        return 1;
    }

    public int getPageNum(){
        if(pageNum != -1){
            return this.pageNum;
        }
        if(pageNum == -1 && currentPage != -1){
            return currentPage;
        }
        return 1;
    }
}
